<?php
include dirname(dirname(dirname(__FILE__))).'/include/user-verify.php';

?>
<!DOCTYPE html>
<html>
<head>
		<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php' ?>
		<script type="text/javascript">
		$(document).ready(function (){
			var _y = <?php echo date('Y'); ?>;
			var _m = <?php echo date('m'); ?>;
			if(_m<10)_m="0"+_m;
			$("#year option[value='"+_y+"']").attr("selected","selected");
			$("#month option[value='"+_m+"']").attr("selected","selected");
			$.ajax({
				dataType:"text",
				url:'ajax/get-worktime.php',
				data:{year:_y,month:_m},
				success:function(data) {
					if(data!='no') {
						$("#work-time").text("你在本月的工时为 "+data+" 小时");
					} else {$("#work-time").text("你在本月没有工时记录");}
				},
			});
			$("select").change(function() {
				var _year = $("#year option:selected").val();
				var _month = $("#month option:selected").val();
				$.ajax({
					dataType:"text",
					url:'ajax/get-worktime.php',
					data:{year:_year,month:_month},
					success:function(data) {
						if(data!='no') {
							$("#work-time").text("你在 "+_year+" 年 "+_month+" 月的工时为 "+data+" 小时");
						} else {$("#work-time").text("你在该月没有工时记录");}
					},
				});
			});
		});</script>
		<link rel="stylesheet" type="text/css" href="../css/style.css">
		<title>用户管理</title>
</head>
<body>
	
	<div class="col-md-12">
		<div>
			<h3>查看个人工时</h3>
		</div>
		<div>
			<form id="submit-form" class="form-inline" role="form">
				选择查询年份<select class="form-control" id="year" name="year" style="margin-left:10px;margin-right:10px;">
					<?php 
						$st = 2014;$end = date('Y');
						for($i=$st;$i<=$end;$i++) {
							echo '<option value="'.$i.'">'.$i.'</option>';
						}
					?>
				</select>
				月份<select class="form-control" id="month" name="month" style="margin-left:10px;">
					<?php 
						for($i=1;$i<=9;$i++) {
							echo '<option value="0'.$i.'">'.$i.'</option>'; 
						}
						for($i=10;$i<=12;$i++) {
							echo '<option value="'.$i.'">'.$i.'</option>'; 	
						}
					?>
				</select>
			</form>
			<h3 id="work-time" style="margin-top:40px;"></h3>
		</div>
	</div>
</body>